--[[/**
-- * 
 * 生命移除
 *
 * 参数[0] 已消耗血量比例
 *
 * 参数[1]：攻击力上限万分比
-- *
-- */]]

---@class BuffEffect128100 : BaseBuffEffect
BuffEffect128100 = ClientFight.CreateClass("BuffEffect128100", ClientFight.BaseBuffEffect)
local t = BuffEffect128100

---@param fight Fight
---@param buff FighterBuff
function t:action(fight, buff, ...)
   local parameters = {...};
    local source = buff.source;
    local target = parameters[1];
    local attrLimitValue = 0;
    local value = buff.buffBean.f_BuffEffectValue[1];
    attrLimitValue = buff.buffBean.f_BuffEffectValue[2];

    local subHp = 0;
    local maxHp = FighterAttributeManager.getFightAttr(target, FighterAttributeEnum.HP);
    local currHp = target.hp;
    subHp = Utils.calcRatio(maxHp - currHp , value);

    local fightAttr = FighterAttributeManager.getFightAttr(source, FighterAttributeEnum.ATK);
    local limitValue =  (fightAttr * toRatio(attrLimitValue));
    if (subHp > limitValue)then
        subHp = limitValue;
    end
    if (subHp < 1) then
    return IBuffEffect.FAIL;
    end
    local logSubHp = subHp;
    SkillRoleMgr.savePathFile(string.format(
    "[%s][EFFECT]Fighter %s Buff%s 触发生命移除,移除%s血量", fight.frame, target.fighterId, buff.modelId, logSubHp
    ));
    local realDamage = DamageManager.setFighterHp(fight, target, source, null, DamageResultTypeEnum.NORMAL,
    -subHp, target.hp - subHp, true, true, true);
    return ClientFight.BaseBuffEffect.action(self, fight, buff, ...);
end

t.New()